package com.winbomb.kingcard.base;

import com.winbomb.kingcard.ICard;
import com.winbomb.kingcard.INegotiate;
import com.winbomb.kingcard.IPlayer;

public class Negotiate implements INegotiate {

	/** 路过的玩家，也就是送礼物的 */
	private IPlayer giver;

	/** 礼物的接受者 */
	private IPlayer accepter;

	/** 作为礼物的卡片 */
	private ICard[] giftCards;

	/** 选中作为礼物的index ， -1表示没有 */
	private int giftIndex;

	private NegoResult result;

	public Negotiate() {
		this.giver = null;
		this.accepter = null;
		this.giftCards = null;
		this.giftIndex = -1;
	}

	@Override
	public ICard[] getGiftCards() {
		return giftCards;
	}

	@Override
	public void newNegotiate(IPlayer giver, IPlayer accepter) {
		this.giver = giver;
		this.accepter = accepter;

		this.giftCards = giver.takeSelectedCards();
	}

	@Override
	public void start() {
		// TODO Auto-generated method stub

	}

	public void selectGift(int index) {
		if (index < 0 || index >= giftCards.length) {
			giftIndex = -1;
			return;
		}

		giftIndex = (giftCards[index] == null) ? -1 : index;
	}

	public void finish() {
	}

	@Override
	public NegoResult getResult() {
		return this.result;
	}

	@Override
	public void setResult(NegoResult result) {
		this.result = result;
	}

}
